﻿@{
    ViewBag.Title = "材料选择";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}

<style type="text/css">
    #print {
        display: none;
    }

    .tool_c {
        padding: 10px 1em;
    }

    .btn-group {
        padding: 0 10px 0 0;
    }

    

    .btn-group:last-child a.btn:first-child {
        margin: 0 0.5em 0 0 !important;
    }

    .input_inline input {
        display: inline-block;
        width: 4em;
    }

    .btn-group input {
        height: 2em !important;
    }
</style>
<script>
    $(function () {
        Index.init();
    });

    var Index = {
        dataList: null,
        init: function () {
            with (Index) {
                loadDataList();

                initControl();
            }
        },
        initControl: function () {
            $("#MaterialNO1").bindSelect({
                url: "/Purchase/MaterialPurchase/GetMaterialCategories",
                id: "MaterialNO",
                text: "MaterialNOName"
            });

            $('select').bindSelect();
            //查询 btn_search1
            $("#btn_search1").on("click", function () {
                var $gridList1 = $("#gridList1");

                var conn1 = $.buildPostParam("MaterialNO,MaterialCode,MaterialSizes", "1");

                $gridList1.jqGrid('setGridParam', {
                    postData: conn1,
                }).trigger('reloadGrid');
            });
        },
        loadDataList: function () {
            var conn1 = $.buildPostParam("MaterialNO,MaterialCode,MaterialSizes", "1");
            
            var $gridList1 = $("#gridList1");

            $gridList1.dataGridForJson({
                url: "/Purchase/MaterialPurchase/GetMaterialCategoriesByPage",
                postData: conn1,
                height: $(window).height() - 150,
                colModel: [
                { label: '材料分类(隐藏)', name: 'MaterialNO', width: 160, align: 'left', sortable: false,hidden:true },
                { label: '材料分类', name: 'MaterialName', width: 80, align: 'center', sortable: false },
                { label: '材料牌号', name: 'MaterialCode', width: 140, align: 'left', sortable: false },
                { label: '材料规格(mm)', name: 'MaterialSizes', width: 140, align: 'left', sortable: false },
                { label: '标准编号', name: 'StandardNumber', width: 120, align: 'left', sortable: false },
                { label: '特殊要求', name: 'MaterialDemand', width: 160, align: 'left', sortable: false }
                ],
                pager: "#gridPager1",
                sortname: 'UseUnit,MaterialCode,MaterialSizes',
                sortorder: "asc,asc,asc",
                viewrecords: true,
                rownumWidth: 50,
                onSelectRow: function (rowId) {
                    var cols = "MaterialNO,MaterialCode,MaterialSizes".split(",");

                    rowData = $gridList1.jqGrid('getRowData', rowId);

                    cols.forEach(function (item) {
                        $("#{0}1".format(item)).val(rowData[item]);
                    });

                    $('select').bindSelect();
                },
                loadComplete: function (data) {
                    Index.dataList = data;
                }
            });

            $gridList1.jqGrid('setFrozenColumns');

            $gridList1.jqGrid('setLabel', 0, '序号', 'rowNumberHeaderStyle');
        }
    };
</script>
<div class="layout" id="layout" style="height: 100%; width: 100%;">
    <div class="tool_c">
        <div class="btn-group input-width-140">
            &nbsp;材料分类<br />
             <select id="MaterialNO1" name="" class="form-control">
                <option value="">--请选择--</option>
            </select>
        </div>
        <div class="btn-group input-width-140">
            &nbsp;材料牌号<br />
            <input id="MaterialCode1" name="" placeholder="" type="text" class="form-control required" />
        </div>
         <div class="btn-group input-width-140">
            &nbsp;材料规格<br />
            <input id="MaterialSizes1" name="" placeholder="" type="text" class="form-control required" />
        </div>
        <div class="btn-group">
            <a id="btn_search1" class="btn btn-primary center-block"><span class="glyphicon glyphicon-search"></span>查询</a>
        </div>
    </div>
    <div class="grid_list_2_c" style="margin-top: 5px;">
        <table id="gridList1"></table>
        <div id="gridPager1"></div>
    </div>
</div>
